﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;

namespace MebAppMarketplace.Biz.Migrations
{
    public partial class init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Apps",
                columns: table => new
                {
                    ID = table.Column<Guid>(nullable: false),
                    CategoryPath = table.Column<string>(nullable: true),
                    CategoryRecommend = table.Column<bool>(nullable: false),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    HomeRecommend = table.Column<bool>(nullable: false),
                    HomeUrl = table.Column<string>(nullable: true),
                    Icon = table.Column<byte[]>(nullable: true),
                    IsOfficalApp = table.Column<bool>(nullable: false),
                    Location = table.Column<string>(nullable: true),
                    Manufacturer = table.Column<string>(nullable: true),
                    NDownload = table.Column<int>(nullable: false),
                    Name = table.Column<string>(nullable: true),
                    NewApp = table.Column<string>(nullable: true),
                    OLTime = table.Column<DateTime>(nullable: false),
                    OwnerID = table.Column<Guid>(nullable: false),
                    Price = table.Column<int>(nullable: false),
                    Version = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Apps", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "AppBases",
                columns: table => new
                {
                    ID = table.Column<Guid>(nullable: false),
                    AppJson = table.Column<string>(nullable: true),
                    CreateTime = table.Column<DateTime>(nullable: false),
                    DeleteTime = table.Column<DateTime>(nullable: true),
                    Deleted = table.Column<bool>(nullable: false),
                    Description = table.Column<string>(nullable: true),
                    IsOffShelve = table.Column<bool>(nullable: false),
                    Name = table.Column<string>(nullable: true),
                    OffShelveReason = table.Column<string>(nullable: true),
                    OwnerID = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppBases", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "MebAppMarketplace",
                columns: table => new
                {
                    ID = table.Column<Guid>(nullable: false),
                    AppName = table.Column<string>(nullable: true),
                    AppVersion = table.Column<string>(nullable: true),
                    Channel = table.Column<string>(nullable: true),
                    Content = table.Column<string>(nullable: true),
                    CreateTime = table.Column<DateTime>(nullable: false),
                    DeviceBrand = table.Column<string>(nullable: true),
                    DeviceID = table.Column<string>(nullable: true),
                    DeviceModel = table.Column<string>(nullable: true),
                    EventTime = table.Column<DateTime>(nullable: false),
                    Name = table.Column<string>(nullable: true),
                    Os = table.Column<string>(nullable: true),
                    PrevEvent = table.Column<string>(nullable: true),
                    StackTrace = table.Column<string>(nullable: true),
                    UserID = table.Column<string>(nullable: true),
                    UserSID = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MebAppMarketplace", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "AppVersions",
                columns: table => new
                {
                    ID = table.Column<Guid>(nullable: false),
                    AppID = table.Column<Guid>(nullable: false),
                    Description = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    Icon = table.Column<byte[]>(nullable: true),
                    Location = table.Column<string>(nullable: true),
                    Manufacturer = table.Column<string>(nullable: true),
                    NDownload = table.Column<int>(nullable: false),
                    Name = table.Column<string>(nullable: true),
                    OLTime = table.Column<DateTime>(nullable: false),
                    Price = table.Column<int>(nullable: false),
                    Version = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppVersions", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Developers",
                columns: table => new
                {
                    ID = table.Column<Guid>(nullable: false),
                    CreateTime = table.Column<DateTime>(nullable: false),
                    Email = table.Column<string>(nullable: true),
                    IsCertificated = table.Column<bool>(nullable: false),
                    Name = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Developers", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "AppUsers",
                columns: table => new
                {
                    ID = table.Column<Guid>(nullable: false),
                    CreateTime = table.Column<DateTime>(nullable: false),
                    Email = table.Column<string>(nullable: true),
                    Enabled = table.Column<bool>(nullable: false),
                    LastLoginAt = table.Column<DateTime>(nullable: true),
                    LastLoginIp = table.Column<string>(nullable: true),
                    LastLoginMachine = table.Column<string>(nullable: true),
                    Password = table.Column<string>(nullable: true),
                    RealName = table.Column<string>(nullable: true),
                    Roles = table.Column<string>(nullable: true),
                    UserName = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppUsers", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "UserApps",
                columns: table => new
                {
                    ID = table.Column<Guid>(nullable: false),
                    AppID = table.Column<Guid>(nullable: false),
                    CreateTime = table.Column<DateTime>(nullable: false),
                    FirstRunTime = table.Column<DateTime>(nullable: true),
                    LastRunTime = table.Column<DateTime>(nullable: true),
                    NAppRuns = table.Column<int>(nullable: false),
                    NCorRuns = table.Column<int>(nullable: false),
                    UserID = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserApps", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "UserRegistrationRequest",
                columns: table => new
                {
                    ID = table.Column<Guid>(nullable: false),
                    AuditState = table.Column<int>(nullable: false),
                    AuditTime = table.Column<DateTime>(nullable: true),
                    CreateTime = table.Column<DateTime>(nullable: false),
                    Email = table.Column<string>(nullable: true),
                    Message = table.Column<string>(nullable: true),
                    RealName = table.Column<string>(nullable: true),
                    RejectReason = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserRegistrationRequest", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "UserWallet",
                columns: table => new
                {
                    ID = table.Column<Guid>(nullable: false),
                    Banlance = table.Column<int>(nullable: false),
                    LockReason = table.Column<string>(nullable: true),
                    LockTime = table.Column<DateTime>(nullable: false),
                    Locked = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserWallet", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "UserWalletHistories",
                columns: table => new
                {
                    ID = table.Column<Guid>(nullable: false),
                    Changes = table.Column<int>(nullable: false),
                    CreateTime = table.Column<DateTime>(nullable: false),
                    LBanlance = table.Column<int>(nullable: false),
                    OpDetail = table.Column<string>(nullable: true),
                    OpName = table.Column<string>(nullable: true),
                    RBanlance = table.Column<int>(nullable: false),
                    UserID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserWalletHistories", x => x.ID);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Apps");

            migrationBuilder.DropTable(
                name: "AppBases");

            migrationBuilder.DropTable(
                name: "MebAppMarketplace");

            migrationBuilder.DropTable(
                name: "AppVersions");

            migrationBuilder.DropTable(
                name: "Developers");

            migrationBuilder.DropTable(
                name: "AppUsers");

            migrationBuilder.DropTable(
                name: "UserApps");

            migrationBuilder.DropTable(
                name: "UserRegistrationRequest");

            migrationBuilder.DropTable(
                name: "UserWallet");

            migrationBuilder.DropTable(
                name: "UserWalletHistories");
        }
    }
}
